<!DOCTYPE html>
<html lang="en">
<head>
    <!--<meta charset="UTF-8">-->
    <title>显示当前的时间</title>
    <script>
        function fun(){
          var date = new Date();
          var h = date.getHours();
          var m = date.getMinutes();
          var s = date.getSeconds();
          m.check(m);
          s.check(s);
          document.getElementById("p").innerHTML=h+":"+m+":"+s;
          t=setTimeout(function(){startTime()},500);
        }
        function check(i){
            if(i<10){
                i = "0"+i;
            }
            return i;
        }

    </script>

</head>
<body onload="fun()">
<p id = "p"></p>
</body>
</html>